package com.hbt.en_rem_hou.controller;

import com.hbt.en_rem_hou.entitys.StaticBean;
import com.hbt.en_rem_hou.entitys.User;
import com.hbt.en_rem_hou.service.UserService;
import com.hbt.en_rem_hou.service.WordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class UserController {

    @Autowired
    UserService userService;

    @Autowired
    WordService wordService;

    @PostMapping("/register")
    public boolean register(User user){
        return userService.register(user);
    }

    @RequestMapping("/getProgress/{userid}")
    public StaticBean getProgress(@PathVariable("userid") int userid){
        return userService.getProgress(userid);
//        return null;
    }

    @RequestMapping("/login")
    public int login(User user){
        System.out.println(user);
        int id = userService.login(user);
        return id;
    }

    @RequestMapping(value = "/getUserInfo/{id}", method = RequestMethod.GET)
    public User getUserInfo(@PathVariable("id") int id){
        System.out.println("getuserinfo--id = "+id);
        return userService.getUserInfoById(id);
    }
}
